﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ePlanet.ArchiveMange.Models;
using ePlanet.ArchiveMange.Services;
using Web.SystemConfig.WorkFlow;
using Web.SystemConfig.SysCache;
using ePlanet.ArchiveBorrow.Enum;
using ePlanet.ArchiveBorrow.Models;
using System.Data;
using DreamBuilder.Core.Container;
using ePlanet.ArchiveBorrow.Services;
using Microsoft.Practices.Unity;
using Web.SystemConfig.Services;
using ePlanet.ArchiveMange.Enum;

namespace Web.Views.ArchiveBorrow.ArchiveBorrowApprove
{
    public partial class ArchiveBorrowDetail : PageBase
    {
        #region 私有属性
        private ArchiveBorrowModel.ARCHIVEBORROWRow m_CurrentArchiveBorrow = null;
        private Web.SystemLogin.Models.User m_CurrentUser
        {
            get
            {
                return (Web.SystemLogin.Models.User)Session["CurrentUser"];
            }
        }

        [Dependency]
        public IArchiveBorrowService m_IArchiveBorrowService
        {
            get;
            set;
        }

        /// <summary>
        /// 是否老借阅逻辑
        /// </summary>
        private bool IsOldArchiveBorrow
        {
            get
            {
                if (string.Equals(Request.QueryString["isBase"], "true", StringComparison.InvariantCultureIgnoreCase))
                {
                    return false;
                }
                return true;
            }
        }

        #endregion

        public string Referer = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            this.GetArchiveBorrowDetail();
            if (!IsPostBack)
            {
                var referer = Request.Headers["Referer"];
                if (!string.IsNullOrEmpty(referer))
                {
                    this.Referer = referer;
                }
                else
                {
                    this.Referer = Request.Url.OriginalString;
                }
                if (IsOldArchiveBorrow)
                {
                    this.SetOperateButtonVisible();
                }
                else
                {
                    SetJCOperateButtonVisible();
                }
                this.BindArchiveBorrowDetail();
                this.SignData();
                this.BindOperateLog();
            }
        }

        #region 信息中心档案借阅逻辑
        #region 初始化
        /// <summary>
        /// 绑定档案形成部门领导信息
        /// </summary>
        /// <param name="statueID"></param>
        /// <param name="operateName"></param>
        private void BindToUserList(int statueID, string operateName)
        {
            WorkFlowMessageStatusRule nextRule = new ArchiveCacheFacade().GetStatusRuleCache().GetRuleByStatusIDAndOperateName(statueID, operateName);
            int toRoleID = nextRule.ToRoleID;
            DataTable toUserList = this.m_IArchiveBorrowService.GetToUserList(toRoleID);
            this.dboToUserList.DataSource = toUserList;
            this.dboToUserList.DataTextField = "UserName";
            this.dboToUserList.DataValueField = "UserID";
            this.dboToUserList.DataBind();
            this.dboToUserList.Items.Insert(0, new ListItem("请选择--"));
        }

        /// <summary>
        /// 初始化档案借阅对象
        /// </summary>
        private void GetArchiveBorrowDetail()
        {
            if (string.IsNullOrEmpty(Request.QueryString["DataID"]))
            {
                throw new Exception("参数DataID不能为空！");
            }
            Guid dataID = new Guid(Request.QueryString["DataID"]);
            ArchiveBorrowModel model = this.m_IArchiveBorrowService.GetSingleArchiveBorrowModelByDataID(dataID);
            if (model != null && model.ARCHIVEBORROW.Count > 0)
            {
                this.m_CurrentArchiveBorrow = model.ARCHIVEBORROW[0];
            }
        }

        /// <summary>
        /// 绑定档案借阅对象
        /// </summary>
        private void BindArchiveBorrowDetail()
        {
            if (this.m_CurrentArchiveBorrow != null)
            {
                this.txtBorrowTime.Text = m_CurrentArchiveBorrow.CREATETIME.ToShortDateString();
                string userID = m_CurrentArchiveBorrow.CREATEUSERID;
                this.txtBorrowUser.Text = m_CurrentArchiveBorrow.BORROWUSERNAME;
                if (!m_CurrentArchiveBorrow.IsUSERORGNAMENull())
                {
                    this.txtBorrowUserOrg.Text = m_CurrentArchiveBorrow.USERORGNAME;
                }
                if (!m_CurrentArchiveBorrow.IsVALIDPERIODNull())
                {
                    this.txtValidPeriod.Text = m_CurrentArchiveBorrow.VALIDPERIOD.ToShortDateString();
                }
                if (!m_CurrentArchiveBorrow.IsCANDOWNLOADNull())
                {
                    this.cboCanDownload.Checked = m_CurrentArchiveBorrow.CANDOWNLOAD == 1 ? true : false;
                }
                if (!m_CurrentArchiveBorrow.IsBORROWREASONNull())
                {
                    this.txtReason.Text = m_CurrentArchiveBorrow.BORROWREASON;
                }

                //外厂借阅，隐藏下载和浏览
                if (m_CurrentArchiveBorrow.BOROWTYPE != null && m_CurrentArchiveBorrow.BOROWTYPE == 1)
                {
                    if (!m_CurrentArchiveBorrow.IsCANVIEWNull())
                    {
                        this.cboCanView.Checked = m_CurrentArchiveBorrow.CANVIEW == 1 ? true : false;
                    }
                    if (!m_CurrentArchiveBorrow.IsVALIDPERIODNull())
                    {
                        this.txtValidPeriod.Text = m_CurrentArchiveBorrow.VALIDPERIOD.ToShortDateString();
                    }
                }
                else
                {
                    //隐藏下载
                    this.trDown.Visible = false;
                    //隐藏本部室审批意见
                    this.trBBSYJ.Visible = false;
                }

                //绑定新加字段 2012-4-13
                //绑定档案类型
                if (!string.IsNullOrEmpty(m_CurrentArchiveBorrow.ARCHIVETYPE))
                {
                    if (m_CurrentArchiveBorrow.USERTYPE.IndexOf("1") != -1)
                    {
                        this.cblARCHIVETYPE.Items[0].Selected = true;
                    }
                    if (m_CurrentArchiveBorrow.USERTYPE.IndexOf("2") != -1)
                    {
                        this.cblARCHIVETYPE.Items[1].Selected = true;
                    }
                    if (m_CurrentArchiveBorrow.USERTYPE.IndexOf("3") != -1)
                    {
                        this.cblARCHIVETYPE.Items[2].Selected = true;
                    }
                }
                //绑定利用方式
                if (!string.IsNullOrEmpty(m_CurrentArchiveBorrow.USERTYPE))
                {
                    if (m_CurrentArchiveBorrow.USERTYPE.IndexOf("1") != -1)
                    {
                        this.cblUSERTYPE.Items[0].Selected = true;
                    }
                    if (m_CurrentArchiveBorrow.USERTYPE.IndexOf("2") != -1)
                    {
                        this.cblUSERTYPE.Items[1].Selected = true;
                    }
                    if (m_CurrentArchiveBorrow.USERTYPE.IndexOf("3") != -1)
                    {
                        this.cblUSERTYPE.Items[2].Selected = true;
                        this.trCopyPage.Visible = true;
                        if (!string.IsNullOrEmpty(m_CurrentArchiveBorrow.COPYPAGE))
                        {
                            this.txtCopyPage.Text = m_CurrentArchiveBorrow.COPYPAGE;
                        }
                    }
                    else
                    {
                        this.trCopyPage.Visible = false;
                    }
                }
                else
                {
                    this.trCopyPage.Visible = false;
                }
                //绑定身份证，电话
                if (!string.IsNullOrEmpty(m_CurrentArchiveBorrow.IDCARD))
                {
                    this.txtIDCARD.Text = m_CurrentArchiveBorrow.IDCARD;
                }
                if (!string.IsNullOrEmpty(m_CurrentArchiveBorrow.TELNUM))
                {
                    this.txtTELNUM.Text = m_CurrentArchiveBorrow.TELNUM;
                }
                //绑定归还时间
                if (this.trReturnTime.Visible)
                {
                    if (!m_CurrentArchiveBorrow.IsRETURNTIMENull())
                    {
                        this.txtReturnTime.Text = m_CurrentArchiveBorrow.RETURNTIME.ToShortDateString();
                    }
                    else
                    {
                        this.txtReturnTime.Text = DateTime.Now.ToShortDateString();
                    }
                }

                this.SetArchiveType();
            }
        }

        private void SetArchiveType()
        {
            string archiveTypeString = string.Empty;
            switch ((int)this.m_CurrentArchiveBorrow.ARCHIVETYPEID)
            {
                case 1:
                    archiveTypeString = "文书类";
                    break;
                case 2:
                    archiveTypeString = "产品类";
                    break;
                case 3:
                    archiveTypeString = "科学技术研究类";
                    break;
                case 4:
                    archiveTypeString = "建设项目类";
                    break;
                case 5:
                    archiveTypeString = "设备仪器类";
                    break;
                case 6:
                    archiveTypeString = "会计类";
                    break;
                case 7:
                    archiveTypeString = "油气勘探类";
                    break;
                case 8:
                    archiveTypeString = "音像类";
                    break;
                case 9:
                    archiveTypeString = "实物类";
                    break;
                default:
                    archiveTypeString = "文书类";
                    break;
            }

            this.txtArchiveType.Text = archiveTypeString;
        }

        private void SetArchiveName(bool isEnable)
        {
            string filter = string.Format("DataID='{0}'", this.m_CurrentArchiveBorrow.ARCHIVEDATAID);
            DataTable oDataTable = new WorkFlow().GetTotalAll(GetArchiveTableEnumByArchiveBaseType((ArchiveTableEnum)this.m_CurrentArchiveBorrow.ARCHIVETYPEID), filter);
            if (oDataTable != null && oDataTable.Rows.Count > 0)
            {
                this.hlArchiveName.Text = oDataTable.Rows[0]["Title"].ToString();
                if (this.m_CurrentArchiveBorrow.CREATEUSERID == this.m_CurrentUser.User_ID)
                {
                    this.hlArchiveName.Enabled = false;
                }
                else
                {
                    this.hlArchiveName.Enabled = true;
                }

                string url = string.Empty;
                if (isEnable)
                {
                    url = string.Format("../../ArchiveView/ArchivePreview.aspx?op=scan&archivetype={0}&archiveId={1}", this.m_CurrentArchiveBorrow.ARCHIVETYPEID, this.m_CurrentArchiveBorrow.ARCHIVEDATAID);
                }
                else
                {
                    url = string.Format("../../ArchiveView/ArchivePreview.aspx?op=readonly&archivetype={0}&archiveId={1}", this.m_CurrentArchiveBorrow.ARCHIVETYPEID, this.m_CurrentArchiveBorrow.ARCHIVEDATAID);
                }

                this.hlArchiveName.NavigateUrl = url;
                //this.hlArchiveName.Enabled = isEnable;
            }
        }

        /// <summary>
        /// 通过档案类型获取表配置类型枚举
        /// </summary>
        /// <returns></returns>
        private ArchiveTableEnum GetArchiveTableEnumByArchiveBaseType(ArchiveTableEnum baseType)
        {
            //ArchiveTableEnum rtnArchiveTableEnum = ArchiveTableEnum.Account;
            //switch (baseType)
            //{
            //    case ArchiveBaseType.Account:
            //        rtnArchiveTableEnum = ArchiveTableEnum.Account;
            //        break;
            //    case ArchiveBaseType.AudioVedio:
            //        rtnArchiveTableEnum = ArchiveTableEnum.AudioVedio;
            //        break;
            //    case ArchiveBaseType.BulidProject:
            //        rtnArchiveTableEnum = ArchiveTableEnum.BulidProject;
            //        break;
            //    case ArchiveBaseType.CDKind:
            //        rtnArchiveTableEnum = ArchiveTableEnum.CDKind;
            //        break;
            //    case ArchiveBaseType.Document:
            //        rtnArchiveTableEnum = ArchiveTableEnum.Document;
            //        break;
            //    case ArchiveBaseType.Equipment:
            //        rtnArchiveTableEnum = ArchiveTableEnum.Equipment;
            //        break;
            //    case ArchiveBaseType.OliSearch:
            //        rtnArchiveTableEnum = ArchiveTableEnum.OliSearch;
            //        break;
            //    case ArchiveBaseType.RealKind:
            //        rtnArchiveTableEnum = ArchiveTableEnum.RealKind;
            //        break;
            //    case ArchiveBaseType.Technology:
            //        rtnArchiveTableEnum = ArchiveTableEnum.Technology;
            //        break;
            //    default:
            //        throw new Exception("未知的文档类型");
            //}
            return baseType;
        }

        /// <summary>
        /// 通过状态，判断文档操作权限
        /// </summary>
        private void SetOperateButtonVisible()
        {
            this.divJCJY.Visible = false;
            this.divXXZXJY.Visible = true;
            int statusId = 0;
            if (this.m_CurrentArchiveBorrow != null)
            {
                statusId = (int)this.m_CurrentArchiveBorrow.STATUSID;
            }
            switch (statusId)
            {
                case 501://本部室领导
                    this.SetBBSLDOperate(true);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    this.SetArchiveName(false);
                    this.SetXXZXDAYOperate2(false);
                    this.SetDAXCBMOperate2(false);
                    break;
                case 502://信息中心档案员
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(true);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    //此状态下，需要选择档案形成部门的领导
                    this.divToUserList.Visible = true;
                    this.BindToUserList(502, ArchiveBorrowEnum.送档案形成部门领导.ToString());
                    this.dboToUserList.Enabled = true;
                    this.SetArchiveName(true);
                    this.SetXXZXDAYOperate2(false);
                    this.SetDAXCBMOperate2(false);

                    //档案员不需要审批意见
                    this.divSP.Visible = false;
                    break;
                case 503://档案形成部门审核中
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(true);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    this.SetArchiveName(true);
                    this.SetXXZXDAYOperate2(false);
                    this.SetDAXCBMOperate2(false);
                    break;
                case 504://信息中心领导
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(true);
                    this.SetPaperArchiveOperate(false);
                    this.SetArchiveName(true);
                    this.SetXXZXDAYOperate2(false);
                    this.SetDAXCBMOperate2(false);
                    break;
                case 505://走完流程的数据，拥有纸质文档借阅接触权限
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(true);
                    this.SetArchiveName(true);
                    this.SetXXZXDAYOperate2(false);
                    this.SetDAXCBMOperate2(false);
                    break;
                case 506://档案员发起的借阅，下一步只有发给档案形成部门
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    this.SetXXZXDAYOperate2(true);
                    this.SetDAXCBMOperate2(false);
                    this.SetArchiveName(true);
                    //此状态下，需要选择档案形成部门的领导
                    this.divToUserList.Visible = true;
                    this.BindToUserList(506, ArchiveBorrowEnum.送档案形成部门.ToString());
                    this.dboToUserList.Enabled = true;
                    break;
                case 507://外厂厂领导审核
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    this.SetXXZXDAYOperate2(false);
                    this.SetDAXCBMOperate2(true);
                    this.SetArchiveName(true);
                    break;
                default://异常状态，不拥有操作权限
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    this.SetXXZXDAYOperate2(false);
                    this.SetArchiveName(true);
                    break;
            }
        }

        /// <summary>
        /// 绑定操作日志
        /// </summary>
        private void BindOperateLog()
        {
            if (this.m_CurrentArchiveBorrow != null)
            {
                DataTable logDt = this.GetWorkFlowLog(this.m_CurrentArchiveBorrow.DATAID);
                if (logDt == null) return;
                DataRow[] BBSLDCommentRows = logDt.Select("OperateID in (1001,1002) and FromStatusID=501");//本部室领导意见
                DataRow[] XXZXDAYCommentRows = logDt.Select("OperateID in (1003,1004,1005) and FromStatusID=502");//档案员审批意见
                DataRow[] DAXCBMLDComnentRows = logDt.Select("OperateID in (1006,1007) and FromStatusID=503");//档案形成部门审批意见
                DataRow[] XXZXLDYJCommentRows = logDt.Select("OperateID in (1008,1009) and FromStatusID=504");//信息中心领导审批意见
                DataRow[] XXZXDAYCommentRowsWC = logDt.Select("OperateID =1011 and FromStatusID=506");//档案员发起借阅，档案员审批意见
                DataRow[] DAXCBMLDComnentRowsWC = logDt.Select("OperateID in (1012,1013) and FromStatusID=507");//档案员发起借阅，档案形成部门审批意见

                //绑定日志
                this.BindCommentData(this.txtMessageBBSLD, BBSLDCommentRows);//绑定本部室领导审批意见
                this.BindCommentData(this.txtMessageDAY, XXZXDAYCommentRows);//档案员审批意见
                this.BindCommentData(this.txtMessageDAXCBMLD, DAXCBMLDComnentRows);//档案形成部门审批意见
                this.BindCommentData(this.txtMessageXXZXLD, XXZXLDYJCommentRows);//信息中心领导审批意见
                if (this.m_CurrentArchiveBorrow.BOROWTYPE == 2)
                {
                    this.BindCommentData(this.txtMessageDAY, XXZXDAYCommentRowsWC);//档案员发起借阅，档案员审批意见
                    this.BindCommentData(this.txtMessageDAXCBMLD, DAXCBMLDComnentRowsWC);//档案形成部门审批意见
                }
            }
        }

        private void BindCommentData(TextBox txt, DataRow[] rows)
        {
            if (rows != null && rows.Length > 0)
            {
                if (rows[0]["commentmessage"] != null && rows[0]["commentmessage"] != DBNull.Value)
                {
                    txt.Text = rows[0]["commentmessage"].ToString();
                }
                else
                {
                    txt.Text = "系统：无审批意见";
                }
            }
        }
        #endregion

        #region 档案借阅角色
        /// <summary>
        /// 本部室领导操作权限
        /// </summary>
        private void SetBBSLDOperate(bool show)
        {
            //拥有不同意、上报信息中心档案员、上报档案员办理借阅权限
            //本部室不同意借阅
            this.btnBBSLDDisAgree.Visible = show;
            //送信息中心档案员
            this.btnBBSLDToXXZX.Visible = show;
        }

        #region 外厂借阅

        /// <summary>
        /// 档案员发起借阅
        /// </summary>
        /// <param name="show"></param>
        private void SetXXZXDAYOperate2(bool show)
        {
            this.btnXXZXDAYToDAXCBMLD2.Visible = show;
        }

        /// <summary>
        /// 档案形成部门领导
        /// </summary>
        /// <param name="show"></param>
        private void SetDAXCBMOperate2(bool show)
        {
            //档案形成部门拥有不同意、送信息中心领导操作
            this.btnDAXCBMLDDisAgree2.Visible = show;
            this.btnDAXCBMToXXZXLD2.Visible = show;
        }
        #endregion


        /// <summary>
        /// 信息中心档案员操作权限
        /// </summary>
        private void SetXXZXDAYOperate(bool show)
        {
            //拥有上报档案形成单位领导、不同意权限
            this.btnXXZXDAYDisAgree.Visible = show;
            this.btnXXZXDAYToDAXCBMLD.Visible = show;
            this.btnDAXCBMLDDisAgree2.Visible = show;
            this.btnXXZXDAYAgreeBorrow.Visible = show;
        }

        /// <summary>
        /// 档案形成部门操作权限
        /// </summary>
        private void SetDAXCBMOperate(bool show)
        {
            //档案形成部门拥有不同意、送信息中心领导操作
            this.btnDAXCBMLDDisAgree.Visible = show;
            this.btnDAXCBMToXXZXLD.Visible = show;
            this.btnDAXCBMToXXZXLD2.Visible = show;
        }

        /// <summary>
        /// 信息中心领导操作权限
        /// </summary>
        private void SetXXZXLDOperate(bool show)
        {
            //信息中心领导拥有不同意、办理借阅操作
            this.btnXXZXLDAgreeBorrow.Visible = show;
            this.btnXXZXLDDisAgree.Visible = show;
        }

        /// <summary>
        /// 纸质文档借阅权限
        /// </summary>
        private void SetPaperArchiveOperate(bool show)
        {
            //Modify by Yidane
            //Date:2014年10月24日06:33:46
            //Reason：在借出时候，不需要显示归还按钮和归还时间；在归还时候，不需要显示借出按钮。
            var isLend = Request.QueryString["Lend"];
            if (show)
            {
                if (string.Equals(isLend, "true", StringComparison.CurrentCultureIgnoreCase))
                {
                    this.btnPaperArchiveLend.Visible = true;
                    this.btnPaperArchiveReturn.Visible = false;
                    this.trReturnTime.Visible = false;
                }
                else
                {
                    this.btnPaperArchiveLend.Visible = false;
                    this.btnPaperArchiveReturn.Visible = true;
                    this.trReturnTime.Visible = true;
                }
                this.divSP.Visible = false;
            }
            else
            {
                this.btnPaperArchiveLend.Visible = false;
                this.btnPaperArchiveReturn.Visible = false;
                this.trReturnTime.Visible = false;
                this.divSP.Visible = true;
            }
        }
        #endregion

        #region 按钮事件
        #region 部室领导操作
        /// <summary>
        /// 部门领导不同意
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnBBSLDDisAgree_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 部室领导同意借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnXXZXDAYAgreeBorrow_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.同意借阅.ToString());
        }

        /// <summary>
        /// 部门领导上报信息中心
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnBBSLDToXXZX_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.送信息中心档案员.ToString());
        }
        #endregion

        #region 档案员操作
        /// <summary>
        /// 信息中心不同意
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnXXZXDAYDisAgree_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 信息中心上报档案形成部门
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnXXZXDAYToDAXCBMLD_Click(object sender, EventArgs e)
        {
            if (this.dboToUserList.SelectedIndex != 0)
            {
                string selectUserID = this.dboToUserList.SelectedValue;
                if (this.m_CurrentArchiveBorrow.STATUSID == 502)
                {
                    this.ProcessWorkFlow(ArchiveBorrowEnum.送档案形成部门领导.ToString(), selectUserID);
                }
                else if (this.m_CurrentArchiveBorrow.STATUSID == 506)
                {
                    this.ProcessWorkFlow(ArchiveBorrowEnum.送档案形成部门.ToString(), selectUserID);
                }
                else
                {
                    Alert("数据状态异常");
                }
            }
            else
            {
                Alert("请先选择档案形成部门领导!");
            }
        }

        /// <summary>
        /// 信息中心上报档案形成部门
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnXXZXDAYToDAXCBMLD2_Click(object sender, EventArgs e)
        {
            if (this.dboToUserList.SelectedIndex != 0)
            {
                string selectUserID = this.dboToUserList.SelectedValue;
                if (this.m_CurrentArchiveBorrow.STATUSID == 506)
                {
                    this.ProcessWorkFlow(ArchiveBorrowEnum.送档案形成部门.ToString(), selectUserID);
                }
                else
                {
                    Alert("数据状态异常");
                }
            }
            else
            {
                Alert("请先选择档案形成部门领导!");
            }
        }

        /// <summary>
        /// 借出纸质文档
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPaperArchiveLend_Click(object sender, EventArgs e)
        {
            DateTime returnTime = DateTime.MinValue;
            //if (string.IsNullOrEmpty(this.txtReturnTime.Text) || (!DateTime.TryParse(this.txtReturnTime.Text.Trim(), out returnTime)))
            //{
            //    Alert("归还时间不能为空");
            //    return;
            //}
            //else
            //{
            this.m_IArchiveBorrowService.PaperArchiveLend(this.m_CurrentArchiveBorrow.DATAID, returnTime);
            MyAlert("借出纸质档案成功", "../ArchiveBorrowView/ArchiveBorrowPaperList.aspx?IsReturn=0");
            //}
        }

        /// <summary>
        /// 归还纸质文档
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPaperArchiveReturn_Click(object sender, EventArgs e)
        {
            this.m_IArchiveBorrowService.PaperArchiveReturn(this.m_CurrentArchiveBorrow.DATAID);
            MyAlert("归还纸质档案成功", "../ArchiveBorrowView/ArchiveBorrowPaperList.aspx?IsReturn=1");
        }

        #endregion

        #region 档案形成部门操作
        /// <summary>
        /// 档案形成部门不同意
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDAXCBMLDDisAgree_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 档案形成部门上报信息中心领导
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDAXCBMToXXZXLD_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.送信息中心领导.ToString());
        }
        #endregion

        #region 档案形成部门厂领导
        /// <summary>
        /// 档案形成部门不同意
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDAXCBMLDDisAgree2_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 档案形成部门上报信息中心领导
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDAXCBMToXXZXLD2_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.送信息中心领导.ToString());
        }
        #endregion

        #region 信息中心领导操作
        /// <summary>
        /// 信息中心领导不同意
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnXXZXLDDisAgree_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 信息中心领导同意办理借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnXXZXLDAgreeBorrow_Click(object sender, EventArgs e)
        {
            this.ProcessWorkFlow(ArchiveBorrowEnum.同意借阅.ToString());
        }

        #endregion
        #endregion

        #region 流程操作
        /// <summary>
        /// 数据签收
        /// </summary>
        private void SignData()
        {
            WorkFlowModel oWorkFlowModel = new WorkFlowModel();
            WorkFlow oWorkFlow = new WorkFlow();
            oWorkFlowModel.TableID = (int)ArchiveTableEnum.ArchiveBorrow;
            oWorkFlowModel.RecordID = new Guid(this.m_CurrentArchiveBorrow.DATAID);
            oWorkFlowModel.FromStatusID = (int)this.m_CurrentArchiveBorrow.STATUSID;
            oWorkFlowModel.FromUserID = new Guid(m_CurrentUser.User_ID);
            oWorkFlow.SignData(oWorkFlowModel);
        }
        /// <summary>
        /// 流程驱动到角色
        /// </summary>
        /// <param name="operateName"></param>
        private void ProcessWorkFlow(string operateName)
        {
            var currentUser = (Web.SystemLogin.Models.User)Session["CurrentUser"];
            if (currentUser == null)
            {
                throw new Exception("无法获取该用户的信息！");
            }

            var commentString = string.Empty;
            //处理审批意见
            if (string.IsNullOrEmpty(this.txtCurrentComment.Text.Trim()))
            {
                if (string.Equals(operateName, "不同意"))
                {
                    commentString = "不同意";
                }
                else
                {
                    commentString = "同意";
                }
            }
            else
            {
                commentString = this.txtCurrentComment.Text.Trim();
            }

            var oWorkFlowModel = new WorkFlowModel
            {
                OperateLogID = Guid.NewGuid(),
                RecordID = new Guid(this.m_CurrentArchiveBorrow.DATAID),
                FromStatusID = (int)this.m_CurrentArchiveBorrow.STATUSID,
                TableID = (int)ArchiveTableEnum.ArchiveBorrow,
                FromUserID = new Guid(currentUser.User_ID),
                CommentMessage = commentString
            };
            WorkFlowMessageStatusRuleListCache ruleCache = new ArchiveCacheFacade().GetStatusRuleCache();
            WorkFlowMessageStatusRule nextRule = ruleCache.GetRuleByStatusIDAndOperateName((int)this.m_CurrentArchiveBorrow.STATUSID, operateName);
            if (nextRule == null)
            {
                throw new Exception("流程配置错误。");
            }
            oWorkFlowModel.OperateID = nextRule.OperateID;
            var oWorkFlow = new WorkFlow();
            oWorkFlow.FlowProcess(oWorkFlowModel);

            if (operateName == ArchiveBorrowEnum.同意借阅.ToString() || operateName == ArchiveBorrowEnum.不同意.ToString())
            {
                oWorkFlow.FlowFinish(ArchiveTableEnum.ArchiveBorrow, this.m_CurrentArchiveBorrow.DATAID);
            }

            if (this.m_CurrentArchiveBorrow.BOROWTYPE > 0)
            {
                MyAlert("操作成功", string.Format("ArchiveBorrowAgent.aspx?borrowtype={0}", (int)this.m_CurrentArchiveBorrow.BOROWTYPE));
            }
        }

        /// <summary>
        /// 流程驱动到人
        /// </summary>
        /// <param name="operateName"></param>
        /// <param name="userID"></param>
        private void ProcessWorkFlow(string operateName, string userID)
        {
            var currentUser = (Web.SystemLogin.Models.User)Session["CurrentUser"];
            if (currentUser == null)
            {
                throw new Exception("无法获取该用户的信息！");
            }
            var UserID = new Guid(userID);
            var oWorkFlowModel = new WorkFlowModel
            {
                OperateLogID = Guid.NewGuid(),
                RecordID = new Guid(this.m_CurrentArchiveBorrow.DATAID),
                FromStatusID = (int)this.m_CurrentArchiveBorrow.STATUSID,
                TableID = (int)ArchiveTableEnum.ArchiveBorrow,
                FromUserID = new Guid(currentUser.User_ID),
                CommentMessage = this.txtCurrentComment.Text.Trim()
            };
            WorkFlowMessageStatusRuleListCache ruleCache = new ArchiveCacheFacade().GetStatusRuleCache();
            WorkFlowMessageStatusRule nextRule = ruleCache.GetRuleByStatusIDAndOperateName((int)this.m_CurrentArchiveBorrow.STATUSID, operateName);
            if (nextRule == null)
            {
                throw new Exception("流程配置错误。");
            }
            oWorkFlowModel.OperateID = nextRule.OperateID;
            var oWorkFlow = new WorkFlow();
            oWorkFlow.FlowProcess(oWorkFlowModel, UserID);

            if (operateName == ArchiveBorrowEnum.同意借阅.ToString())
            {
                oWorkFlow.FlowFinish(ArchiveTableEnum.ArchiveBorrow, this.m_CurrentArchiveBorrow.DATAID);
            }

            if (this.m_CurrentArchiveBorrow.BOROWTYPE > 0)
            {
                MyAlert("操作成功", string.Format("ArchiveBorrowAgent.aspx?borrowtype={0}", (int)this.m_CurrentArchiveBorrow.BOROWTYPE));
            }
        }

        /// <summary>
        /// 驱动数据
        /// </summary>
        /// <param name="operateName"></param>
        /// <param name="qzh"></param>
        private void ProcessWorkFlow2(string operateName)
        {
            try
            {
                var currentUser = (Web.SystemLogin.Models.User)Session["CurrentUser"];
                if (currentUser == null)
                {
                    throw new Exception("无法获取该用户的信息！");
                }
                var oWorkFlowModel = new WorkFlowModel
                {
                    OperateLogID = Guid.NewGuid(),
                    RecordID = new Guid(this.m_CurrentArchiveBorrow.DATAID),
                    FromStatusID = (int)this.m_CurrentArchiveBorrow.STATUSID,
                    TableID = (int)ArchiveTableEnum.ArchiveBorrow,
                    FromUserID = new Guid(currentUser.User_ID),
                    CommentMessage = this.txtCurrentComment.Text.Trim()
                };
                WorkFlowMessageStatusRuleListCache ruleCache = new ArchiveCacheFacade().GetStatusRuleCache();
                WorkFlowMessageStatusRule nextRule = ruleCache.GetRuleByStatusIDAndOperateName((int)this.m_CurrentArchiveBorrow.STATUSID, operateName);
                if (nextRule == null)
                {
                    throw new Exception("流程配置错误。");
                }
                oWorkFlowModel.OperateID = nextRule.OperateID;
                var oWorkFlow = new WorkFlow();

                //获取驱动用户列表
                var oIAuth_User = UContainer.Resolve<IAuth_User>();
                var toUserList = oIAuth_User.GetUserListByQZHAndToRoleID(this.GetQuanZonghao(), nextRule.ToRoleID.ToString());
                if (toUserList == null || toUserList.Count == 0)
                    throw new Exception(string.Format("通过全宗号定位到的组织机构无RoleID={0}的用户", nextRule.ToRoleID.ToString()));

                oWorkFlow.FlowProcess(oWorkFlowModel, toUserList);

                if (operateName == ArchiveBorrowEnum.同意借阅.ToString())
                {
                    oWorkFlow.FlowFinish(ArchiveTableEnum.ArchiveBorrow, this.m_CurrentArchiveBorrow.DATAID);
                }

                if (this.m_CurrentArchiveBorrow.BOROWTYPE > 0)
                {
                    MyAlert("操作成功", string.Format("ArchiveBorrowAgent.aspx?borrowtype={0}", (int)this.m_CurrentArchiveBorrow.BOROWTYPE));
                }
            }
            catch (Exception ex)
            {
                Alert(ex.Message);
            }
        }

        /// <summary>
        /// 获取全宗号
        /// </summary>
        /// <returns></returns>
        private string GetQuanZonghao()
        {
            object searchResult = null;
            switch ((ArchiveTableEnum)this.m_CurrentArchiveBorrow.ARCHIVETYPEID)
            {
                case ArchiveTableEnum.Account:
                case ArchiveTableEnum.AccountI01:
                case ArchiveTableEnum.AccountI02:
                case ArchiveTableEnum.AccountI03:
                case ArchiveTableEnum.AccountI04:
                    var AccountArchiveService = UContainer.Resolve<IAccountArchiveService>();
                    searchResult = ((ArchiveMangeModal.ACCOUNT_VOUCHER_ARCHIVERow)AccountArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.AudioVedio:
                case ArchiveTableEnum.AudioVedioS01:
                case ArchiveTableEnum.AudioVedioS02:
                case ArchiveTableEnum.AudioVedioS03:
                    var AudioVedioArchiveService = UContainer.Resolve<IAccountArchiveService>();
                    searchResult = ((ArchiveMangeModal.AUDIOVEDIO_ARCHIVERow)AudioVedioArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.BulidProject:
                    var BulidProjectVedioArchiveService = UContainer.Resolve<IAccountArchiveService>();
                    searchResult = ((ArchiveMangeModal.BULIDPROJECT_ARCHIVERow)BulidProjectVedioArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.CDKind:
                    var CDKindArchiveService = UContainer.Resolve<IAccountArchiveService>();
                    searchResult = ((ArchiveMangeModal.CD_ARCHIVERow)CDKindArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.Document:
                    var DocumentArchiveService = UContainer.Resolve<IDocumentArchiveService>();
                    searchResult = ((ArchiveMangeModal.DOCUMENT_ARCHIVERow)DocumentArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.Equipment:
                    var EquipmentArchiveService = UContainer.Resolve<IDocumentArchiveService>();
                    searchResult = ((ArchiveMangeModal.EQUIPMENT_ARCHIVERow)EquipmentArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.OliSearch:
                case ArchiveTableEnum.OliSearchK01:
                case ArchiveTableEnum.OliSearchK02:
                    var OliSearchArchiveService = UContainer.Resolve<IDocumentArchiveService>();
                    searchResult = ((ArchiveMangeModal.OLISEARCH_ARCHIVERow)OliSearchArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.RealKind:
                case ArchiveTableEnum.RealKindR02:
                case ArchiveTableEnum.RealKindR03:
                case ArchiveTableEnum.RealKindR04:
                    var RealKindArchiveService = UContainer.Resolve<IDocumentArchiveService>();
                    searchResult = ((ArchiveMangeModal.REALKIND_ARCHIVERow)RealKindArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                case ArchiveTableEnum.Technology:
                    var TechnologyArchiveService = UContainer.Resolve<IDocumentArchiveService>();
                    searchResult = ((ArchiveMangeModal.TECHNOLOGY_ARCHIVERow)TechnologyArchiveService.GetAllDocumenArchivetDataById(this.m_CurrentArchiveBorrow.ARCHIVEDATAID).Rows[0]).FULLFONDSNUM;
                    break;
                default:
                    throw new Exception(string.Format("异常的档案类型:{0}", m_CurrentArchiveBorrow.ARCHIVETYPEID));
            }

            if (searchResult == null || string.IsNullOrEmpty(searchResult.ToString()))
                throw new Exception("该档案数据全宗号为空");

            return searchResult.ToString();
        }

        /// <summary>
        /// 获取操作日志
        /// </summary>
        /// <param name="dataID"></param>
        /// <returns></returns>
        private DataTable GetWorkFlowLog(string dataID)
        {
            WorkFlow oWorkFlow = new WorkFlow();
            return oWorkFlow.GetOperateLogList(ArchiveTableEnum.ArchiveBorrow, dataID);
        }

        #endregion
        #endregion

        #region 基层档案借阅

        #region 按钮事件

        /// <summary>
        /// 基层本部室领导上报档案形成部门档案员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCBBSLDToDAXCBMDAY_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow2(ArchiveBorrowEnum.基层送档案形成部门档案员.ToString());
        }

        /// <summary>
        /// 基层本部室领导不同意借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCBBSLDDisAgree_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 档案形成部门档案员同意借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCDAXCBMDAYAgree_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.同意借阅.ToString());
        }

        /// <summary>
        /// 档案形成部门档案员上报档案形成部门领导
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCDAXCBMDAYToDAXCBMLD_Click(object sender, EventArgs e)
        {
            //需要选择人员
            if (this.dboToUserList.SelectedIndex != 0)
            {
                string selectUserID = this.dboToUserList.SelectedValue;
                if (this.m_CurrentArchiveBorrow.STATUSID == 511)
                {
                    this.ProcessWorkFlow(ArchiveBorrowEnum.基层送档案形成部室领导.ToString(), selectUserID);
                }
                else
                {
                    Alert("数据状态异常");
                }
            }
            else
            {
                Alert("请先选择档案形成部室领导!");
            }
        }

        /// <summary>
        /// 档案形成部门档案员不同意借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCDAXCBMDAYDisAgree_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 档案形成部门领导上报档案员领导
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCDAXCBMLDToDAYLD_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow2(ArchiveBorrowEnum.基层送档案员领导.ToString());
        }

        /// <summary>
        /// 档案形成部门领导不同意借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCDAXCBMLDDisAgree_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        /// <summary>
        /// 档案员领导同意借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCDAYLDAgree_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.同意借阅.ToString());
        }

        /// <summary>
        /// 档案员领导不同意借阅
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnJCDAYLDDisAgree_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }

        //----------------基层代理借阅--------------//
        protected void btn2ToDAXCBMLD_Click(object sender, EventArgs e)
        {
            //需要选择人员
            if (this.dboToUserList.SelectedIndex != 0)
            {
                string selectUserID = this.dboToUserList.SelectedValue;
                if (this.m_CurrentArchiveBorrow.STATUSID == 516)
                {
                    this.ProcessWorkFlow(ArchiveBorrowEnum.基层送档案形成部门领导.ToString(), selectUserID);
                }
                else
                {
                    Alert("数据状态异常");
                }
            }
            else
            {
                Alert("请先选择档案形成部门领导!");
            }
        }

        protected void btn2ToDAYLD_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.基层送档案员领导.ToString());
        }

        protected void btn2DAXCBMLDDisAgree_Click(object sender, EventArgs e)
        {
            ProcessWorkFlow(ArchiveBorrowEnum.不同意.ToString());
        }
        //------------------------------//
        #endregion

        #region 按钮权限
        /// <summary>
        /// 本部室领导权限
        /// </summary>
        /// <param name="isShow"></param>
        private void SetJCBBSLD(bool isShow)
        {
            this.btnJCBBSLDDisAgree.Visible = isShow;
            this.btnJCBBSLDToDAXCBMDAY.Visible = isShow;
        }

        /// <summary>
        /// 基层档案员权限
        /// </summary>
        /// <param name="isShow"></param>
        private void SetJCDAXCBMDAY(bool isShow)
        {
            this.btnJCDAXCBMDAYAgree.Visible = isShow;
            this.btnJCDAXCBMDAYDisAgree.Visible = isShow;
            this.btnJCDAXCBMDAYToDAXCBMLD.Visible = isShow;
        }

        /// <summary>
        /// 基层档案形成部门领导权限
        /// </summary>
        /// <param name="isShow"></param>
        private void SetJCDAXCBMLD(bool isShow)
        {
            this.btnJCDAXCBMLDDisAgree.Visible = isShow;
            this.btnJCDAXCBMLDToDAYLD.Visible = isShow;
        }

        /// <summary>
        /// 档案员领导权限
        /// </summary>
        /// <param name="isShow"></param>
        private void SetJCDAYLD(bool isShow)
        {
            this.btnJCDAYLDAgree.Visible = isShow;
            this.btnJCDAYLDDisAgree.Visible = isShow;
        }

        ///////////////////////////////////////档案员代理借阅

        private void SetJCDAXCBMDAY2(bool isShow)
        {
            this.btn2ToDAXCBMLD.Visible = isShow;
        }

        private void SetJCDAXCBMLD2(bool isShow)
        {
            this.btn2DAXCBMLDDisAgree.Visible = isShow;
            this.btn2ToDAYLD.Visible = isShow;
        }

        ///////////////////////////////////////

        /// <summary>
        /// 设置基层操作权限
        /// </summary>
        private void SetJCOperateButtonVisible()
        {
            this.divXXZXJY.Visible = false;
            this.divJCJY.Visible = true;
            int statusId = 0;
            if (this.m_CurrentArchiveBorrow != null)
            {
                statusId = (int)this.m_CurrentArchiveBorrow.STATUSID;
            }
            switch (statusId)
            {
                case 510://本部室领导
                    this.SetJCBBSLD(true);
                    this.SetJCDAXCBMDAY(false);
                    this.SetJCDAXCBMLD(false);
                    this.SetJCDAYLD(false);
                    this.SetArchiveName(false);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(false);
                    break;
                case 511://档案形成部门档案员
                    this.SetJCBBSLD(false);
                    this.SetJCDAXCBMDAY(true);
                    this.SetJCDAXCBMLD(false);
                    this.SetJCDAYLD(false);
                    //绑定档案形成部室领导，供档案员选择使用
                    BindToUserList(511, ArchiveBorrowEnum.基层送档案形成部室领导.ToString());
                    this.divToUserList.Visible = true;
                    this.dboToUserList.Enabled = true;
                    this.SetArchiveName(true);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(false);
                    break;
                case 512://档案形成部门领导
                    this.SetJCBBSLD(false);
                    this.SetJCDAXCBMDAY(false);
                    this.SetJCDAXCBMLD(true);
                    this.SetJCDAYLD(false);
                    this.SetArchiveName(true);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(false);
                    break;
                case 513://档案员领导
                    this.SetJCBBSLD(false);
                    this.SetJCDAXCBMDAY(false);
                    this.SetJCDAXCBMLD(false);
                    this.SetJCDAYLD(true);
                    this.SetArchiveName(true);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(false);
                    break;
                case 516://档案员发起借阅
                    this.SetJCBBSLD(false);
                    this.SetJCDAXCBMDAY(false);
                    this.SetJCDAXCBMLD(false);
                    this.SetJCDAYLD(false);
                    //绑定档案形成部门领导，供档案员选择使用
                    BindToUserList(516, ArchiveBorrowEnum.基层送档案形成部门领导.ToString());
                    this.divToUserList.Visible = true;
                    this.dboToUserList.Enabled = true;
                    this.SetArchiveName(true);
                    this.SetJCDAXCBMDAY2(true);
                    this.SetJCDAXCBMLD2(false);
                    break;
                case 517://本部门领导审阅
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    this.SetXXZXDAYOperate2(false);
                    this.SetArchiveName(true);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(false);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(true);
                    break;
                default://异常状态，不拥有操作权限
                    this.SetBBSLDOperate(false);
                    this.SetDAXCBMOperate(false);
                    this.SetXXZXDAYOperate(false);
                    this.SetXXZXLDOperate(false);
                    this.SetPaperArchiveOperate(false);
                    this.SetXXZXDAYOperate2(false);
                    this.SetArchiveName(true);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(false);
                    this.SetJCDAXCBMDAY2(false);
                    this.SetJCDAXCBMLD2(false);
                    break;
            }
        }
        #endregion

        #endregion

        private new void Alert(string message)
        {
            //Response.Write("<script>alert('" + message + "');</script>");
            //这样写，可以解决弹出框关闭后样式走样的问题
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMsg", "<script>alert('" + message + "');</script>", false);
        }

        private new void MyAlert(string msg, string url)
        {
            //this.Response.Write("<script>alert(\"" + msg + "\");window.location.href=\"" + url + "\"</script>");
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMsg", "<script>alert(\"" + msg + "\");window.location.href=\"" + url + "\"</script>", false);
        }
    }
}